// POJ 2367
// DFS
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <vector>
#include <list>
using namespace std;

const int N = 102;
int n;

list<int> adj[N];

bool visited[N];

vector<int> res;

void dfs(int i)
{
	if (!visited[i])
	{
		for (list<int>::iterator j = adj[i].begin(); j != adj[i].end(); ++j)
			dfs(*j);
		res.push_back(i);
		visited[i] = true;
	}
}

int main()
{
	memset(visited, 0, sizeof(visited));
	int n, t;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		while (scanf("%d", &t) && t != 0)
			adj[i].push_back(t);
	for (int i = 1; i <= n; ++i)
		dfs(i);
	for (int i = res.size() - 1; i >= 0; --i)
		printf("%d ", res[i]);
   	 system("pause");
   	 return 0;
}

// Queue
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <vector>
#include <list>
#include <queue>
using namespace std;

const int N = 102;
int n;

list<int> adj[N];

int indegree[N];

vector<int> res;

int main()
{
	memset(indegree, 0, sizeof(indegree));
	int n, t;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		while (scanf("%d", &t) && t != 0)
		{
			++indegree[t];
			adj[i].push_back(t);
		}
	queue<int> q;
	for (int i = 1; i <= n; ++i)
		if (indegree[i] == 0)
			q.push(i);
	while (!q.empty())
	{
		int nd = q.front();
		q.pop();
		res.push_back(nd);
		for (list<int>::iterator i = adj[nd].begin(); i != adj[nd].end(); ++i)
			if (--indegree[*i] == 0)
				q.push(*i);
	}
	//if (res.size() != n)
	//	printf("Circle appeared!");
	for (int i = 0; i < res.size(); ++i)
		printf("%d ", res[i]);
    system("pause");
    return 0;
}